home *** CD-ROM | disk | FTP | other *** search
- DEFINT A-Z
-
- ' Start this as "qb /Lbitstuff bittest" to use the supplied .QLB
- ' See the .DOC file and the MASM source file for more details
-
- DECLARE SUB SetBit (bitnum%, word%)
- DECLARE SUB ClearBit (bitnum%, word%)
- DECLARE SUB ToggleBit (bitnum%, word%)
- DECLARE FUNCTION BitState% (bitnum%, word%)
-
- DECLARE FUNCTION BitStr$ (word%)
-
- DECLARE FUNCTION BitVal& (ones$)
-
- '''DECLARE FUNCTION BitVal% (ones$)
-
- ' Change the declaration as shown above to see the difference in how QB
- ' interprets the same 16 bit quantity when it thinks it's an integer.
-
- CLS
-
- v$ = "│"
- FOR k = 0 TO 16 'bit positions 1 through 16
- a = -1
- b = 0
- ClearBit k, a: SetBit k, b
- a$ = BitStr(a)
- b$ = BitStr(b)
- PRINT b, b$; v$; BitVal(b$), a, a$; v$; BitVal(a$)
- NEXT
-
- bt$ = "10101"
- PRINT
- PRINT "States of the individual bits in "; bt$; "..."
- PRINT
- FOR k = 1 TO 5
- PRINT BitState(k, BitVal(bt$)),
- NEXT
-
-